//自动派单设置
import { Button, Form, Input, Table, Pagination, Space, Modal, Switch } from 'antd';
import { SearchOutlined, PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons';
import { useEffect, useState, FC, ReactNode } from 'react';
import type { ColumnsType } from 'antd/lib/table';
import '../index.css'
import http from '../../../../utils/http';
interface DataType {
  key: string;
  Materials: string;

}
const AutoSingle: FC = () => {
  // 获取数据
  const [data1, setData] = useState([])
  const getData = () => {
    http({
      url: ' string',
      method: 'get',
      params: data,
    }).then((res) => {
      console.log(res);
      if (res.code) { setData(res.data) }
    }).catch()
  }
  // 加载开始获取数据
  useEffect(() => { getData() }, [])
  const selectname = () => { }
  const [form] = Form.useForm();
  // 批量启用
  const [type, setType] = useState('')
  const allstart = () => {
    setType('1');
    http({ url: '/type', method: 'post', data: type }).then().catch()

  }
  //批量关闭
  const alldel = () => {
    setType('0');
    http({ url: '/type', method: 'post', data: type })
  }
  const columns: ColumnsType<DataType> = [
    {
      title: '序号',
      dataIndex: 'key'
    },
    {
      title: '物料组',
      dataIndex: 'Materials'
    },
    {
      title: '启用状态',
      dataIndex: 'type',
      render: () => (
        <Switch checkedChildren="开启" onChange={() => { }} unCheckedChildren="关闭" defaultChecked />
      )
      // 点击alladd全选，点alldel全不选，全选的状态应该是获取数据来决定的，要传参过来
    },
  ]
  const data: DataType[] = [
    {
      key: '1',
      Materials: '物料组1',

    },
    {
      key: '2',
      Materials: '物料组2',

    },
    {
      key: '3',
      Materials: '物料组3',

    },
  ]

  return <div>

    <Form form={form} layout="inline" className='btnStyel'>
      <Form.Item >物料组:<Input className='inp' /></Form.Item>
      <Form.Item><Button icon={<SearchOutlined />} style={{ borderColor: 'rgb(2,167,240)', color: 'rgb(2,167,240)' }} onClick={selectname}>查询</Button></Form.Item>

    </Form>

    <div style={{ margin: '1.25rem' }}><Button style={{ margin: '0.25rem' }} type="primary" icon={<PlusCircleOutlined />} onClick={allstart}>批量启用</Button>
      <Button style={{ margin: '0.25rem' }} type="primary" icon={<MinusCircleOutlined />} onClick={alldel}>批量关闭</Button></div>

    <Table
      columns={columns}
      dataSource={data}
      bordered
      pagination={false}
    />



  </div>
}

export default AutoSingle